<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE html>
<html>
<head>
<title>项目管理工具</title>
<meta charset="gbk">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap-3.3.7-dist/css/bootstrap.min.css">
<script src="bootstrap-3.3.7-dist/js/jquery.min.js"></script>
<script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<style type="text/css">
body {
	margin: 0px;
	background: url(style/image/background/bangongshi1xh.jpg) no-repeat;
	background-size: 100% 100%;
	background-attachment: fixed;

}

.group {
	height: 400px;
	width: 800px;
}

.grouplist {
background: url(style/image/background/card1.png) no-repeat;
    background-size: 100% 100%;
	float: left;
	height: 200px;
	width: 400px;
	font-size: 15px;
}

.grouplist:hover {
	 background: url(style/image/background/card2.png) no-repeat;
	 background-size: 100% 100%;
}

.im {
	padding-top: 25px;
	padding-left: 40px;
	float: left;
	height: 150px;
	width: 100px;
}

.imright {
	float: left;
	padding-top: 25px;
	padding-left: 50px;
	height: 200px;
	width: 300px;
	line-height: 2.0;
}

.typetop {
	
}

.typechild {
	margin-left: 750px;
}
.teamUserFenYe{
	margin-left: 750px;
 	margin-top:800px;
}
.pagination{
	width:400px;
}
#teamUserFenYe{
    margin-left: 250px;
	width:100px;
}
</style>
<script>



	$(function() {
		$(".dropdown-toggle").dropdown();
		var type1=document.getElementById("type1");
		var type2=document.getElementById("type2");
		type1.style.display='block';
		type2.style.display='none';
		
	});
	
	
	
	function changeType1(){
		var type1=document.getElementById("type1");
		var type2=document.getElementById("type2");
		type1.style.display='block';
		type2.style.display='none';
		
	}
	function changeType2(){
		var type1=document.getElementById("type1");
		var type2=document.getElementById("type2");
		type1.style.display='none';
		type2.style.display='block';
		
	}
	function passApply(applyUserid){
		window.location.href="passAppluUser.do?applyUserid="+applyUserid+"&teamid=${nowteamid}";
	}
	
	
	
	function deleteTeamMember(userid,teamid,teamUserNowNo){
//		alert(userName);
		
		
		
		var teamMember=document.getElementById("panel-808913");
		var type1=document.getElementById("type1");
		var type2=document.getElementById("type2");
		var teamUserFenYe=document.getElementById("teamUserFenYe");
		
		var param="userid="+userid+"&teamid="+teamid+"&teamUserNowNo="+teamUserNowNo;
//		alert(param);
		$.ajax({
	      	type: 'post',
	      	url:'deleteTeamMember.do',
	      	data: param,
	      	success:function(data){
	      
	      	//alert(data);
	      var  type1html="";
			var  type2html;
			
			$("#type1").empty();
			$("#type2").empty();
			$("#teamUserFenYe").empty();
			type2html="<div class='table-responsive'><table class='table'><thead><tr><th><center>成员名称</center></th><th><center>成员评分</center></th><th><center>移除</center></th></tr></thead><tbody>";
            var createUserName="${createUserName}";
			         

		

	      	var dataObj=eval("(" + data + ")");
	      	var teamUserNowNo;
	      	var teamUserTotalNo;
	      	for(var i=0;i<dataObj.length;i++){
		      	var proAttr=dataObj[i];
		      	var tel=proAttr.tel;
		      	var userid=proAttr.userId;
		      	var username=proAttr.userName;
		      	var email=proAttr.email;
		      	var headimage=proAttr.headimage;
		      	var teamScore=proAttr.teamScore;
		      	teamUserNowNo=proAttr.teamUserNowNo;
		      	teamUserTotalNo=proAttr.teamUserTotalNo;
		      	type1html+="<div class='grouplist'><div class='im'><img src='"+headimage+"' height='100' width='100' /></div><div class='imright'>姓名："+username+"</br> 邮箱："+email+"</br> 电话:"+tel+"</br> 团队评分："+teamScore+"</br>";
		      	type2html+="<tr><td><center>"+username+"</center></td><td><center>"+teamScore+"</center></td><td><center>";
	      		
		      	if(createUserName==username){
		      		type1html+="</div></div>";
		      		type2html+="</center></td></tr>";
		      	}else{
		      		type1html+="<button type='button' class='btn btn-default btn-sm' onclick='deleteTeamMember("+userid+","+teamid+","+teamUserNowNo+")'><span class='glyphicon glyphicon-remove'></span> Remove</button></div></div>";
		      		type2html+="<button type='button' class='btn btn-default btn-sm' onclick='deleteTeamMember("+userid+","+teamid+","+teamUserNowNo+")'><span class='glyphicon glyphicon-remove'></span> Remove</button></center></td></tr>";
		      	}
		      	
		      
		      	}
	      		type2html+="</tbody></table></div>";
	      		type2.innerHTML+=type2html;
	      		type1.innerHTML+=type1html;
	      		
				if(teamUserNowNo==1&&teamUserNowNo==teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul style='width:400px;' class='pagination'><li><a>共"+teamUserTotalNo+"页</a></li><li><a>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo==1&&teamUserNowNo!=teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul style='width:400px;' class='pagination'><li><a>共"+teamUserTotalNo+"页</a></li><li><a>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo+1)+")'>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo==teamUserTotalNo && teamUserNowNo!=1){
					teamUserFenYe.innerHTML="<center><ul style='width:400px;' class='pagination'><li><a>共"+teamUserTotalNo+"页</a></li><li><a href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo-1)+")'>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo!=1&&teamUserNowNo!=teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul style='width:400px;' class='pagination'><li><a>共"+teamUserTotalNo+"页</a></li><li><a 	href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo-1)+")'>Prev</a></li><li><a>${teamUserNowNo}</a></li><li><a	href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo+1)+")'>Next</a></li></ul></center>";
					
				}	
			
					
				
		
		
	      	  },
	      	  error:function(){
		        alert("出错了！");
		           }
	      	});
	}
	
	
	function teamUserFenYe(teamid,teamUserNowNo){
		

		var teamMember=document.getElementById("panel-808913");
		var type1=document.getElementById("type1");
		var type2=document.getElementById("type2");
		var teamUserFenYe=document.getElementById("teamUserFenYe");
		
		var param="teamid="+teamid+"&teamUserNowNo="+teamUserNowNo;
//		alert(param);
		$.ajax({
	      	type: 'post',
	      	url:'teamUserFenYe.do',
	      	data: param,
	      	success:function(data){
	      
	      	//alert(data);
	      
			
			
			$("#type1").empty();
			$("#type2").empty();
			$("#teamUserFenYe").empty();
			var  type1html="";
			var  type2html;
			type2html="<div class='table-responsive'><table class='table'><thead><tr><th><center>成员名称</center></th><th><center>成员评分</center></th><th><center>移除</center></th></tr></thead><tbody>";
			                 
			var createUserName="${createUserName}";
		

	      	var dataObj=eval("(" + data + ")");
	      	var teamUserNowNo;
	      	var teamUserTotalNo;
	      	for(var i=0;i<dataObj.length;i++){
		      	var proAttr=dataObj[i];
		      	var tel=proAttr.tel;
		      	var userid=proAttr.userId;
		      	var username=proAttr.userName;
		   
		      	var email=proAttr.email;
		      	var headimage=proAttr.headimage;
		      	var teamScore=proAttr.teamScore;
		      	teamUserNowNo=proAttr.teamUserNowNo;
		      	teamUserTotalNo=proAttr.teamUserTotalNo;
		      	 type1html+="<div class='grouplist'><div class='im'><img src='"+headimage+"' height='100' width='100' /></div><div class='imright'>姓名："+username+"</br> 邮箱："+email+"</br> 电话:"+tel+"</br> 团队评分："+teamScore+"</br>";
		      	type2html+="<tr><td><center>"+username+"</center></td><td><center>"+teamScore+"</center></td><td><center>";
		      	
		      	if(createUserName==username){
		      		 type1html+="</div></div>";
		      		type2html+="</center></td></tr>";
		      	}else{
		      		 type1html+="<button type='button' class='btn btn-default btn-sm' onclick='deleteTeamMember("+userid+","+teamid+","+teamUserNowNo+")'><span class='glyphicon glyphicon-remove'></span> Remove</button></div></div>";
		      		type2html+="<button type='button' class='btn btn-default btn-sm' onclick='deleteTeamMember("+userid+","+teamid+","+teamUserNowNo+")'><span class='glyphicon glyphicon-remove'></span> Remove</button></center></td></tr>";
		      	}
		      	
		      
		      	}
	      		type2html+="</tbody></table></div>";
	      		type2.innerHTML+=type2html;
	      		type1.innerHTML+=type1html;
	      		
				if(teamUserNowNo==1&&teamUserNowNo==teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul  class='pagination' style='width:400px;'><li style='width:200px;'><a>共"+teamUserTotalNo+"页</a></li><li><a>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo==1&&teamUserNowNo!=teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul  class='pagination' style='width:400px;'><li style='width:200px;'><a>共"+teamUserTotalNo+"页</a></li><li><a>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo+1)+")'>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo==teamUserTotalNo && teamUserNowNo!=1){
					teamUserFenYe.innerHTML="<center><ul  class='pagination' style='width:400px;'><li style='width:200px;'><a>共"+teamUserTotalNo+"页</a></li><li><a href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo-1)+")'>Prev</a></li><li><a>"+teamUserNowNo+"</a></li><li><a>Next</a></li></ul></center>";
					
				}
				if(teamUserNowNo!=1&&teamUserNowNo!=teamUserTotalNo){
					teamUserFenYe.innerHTML="<center><ul  class='pagination' style='width:400px;'><li style='width:200px;'><a>共"+teamUserTotalNo+"页</a></li><li><a 	href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo-1)+")'>Prev</a></li><li><a>${teamUserNowNo}</a></li><li><a	href='javascript:teamUserFenYe(${nowteamid},"+(teamUserNowNo+1)+")'>Next</a></li></ul></center>";
					
				}	
			
					
				
		
		
	      	  },
	      	  error:function(){
		        alert("出错了！");
		           }
	      	});
	}
</script>

</head>
<body>

	<div class="container">
		<div class="row clearfix">
			<div class="col-md-12 column">
				<nav class="navbar navbar-default" role="navigation">
					<div class="navbar-header">
						<button type="button" class="navbar-toggle" data-toggle="collapse"
							data-target="#bs-example-navbar-collapse-1">
							<span class="sr-only">Toggle navigation</span><span
								class="icon-bar"></span><span class="icon-bar"></span><span
								class="icon-bar"></span>
						</button>

					</div>

					<div class="collapse navbar-collapse"
						id="bs-example-navbar-collapse-1">
						<ul class="nav navbar-nav">

							<li class="dropdown"><a href="#" class="dropdown-toggle"
								data-toggle="dropdown">项目管理工具<strong class="caret"></strong></a>
								<ul class="dropdown-menu">

									<li class="divider"></li>
									<li><a>切换团队</a></li>
									<li class="divider">切换团队</li>
									<c:if test="${empty allTeam}">
									</c:if>
									<c:if test="${not empty allTeam}">
										<c:forEach var="team" items="${allTeam}">
											<c:if test="${team.teamid eq nowteamid}">
												<li><a href="gotoTeamDetail.do?teamid=${team.teamid}">${team.teamname}
														&nbsp; &nbsp;<span class="glyphicon glyphicon-ok"></span>
												</a></li>
											</c:if>
											<c:if test="${team.teamid  ne nowteamid}">
												<li><a href="gotoTeamDetail.do?teamid=${team.teamid}">${team.teamname}</a></li>
											</c:if>

										</c:forEach>
										<li class="divider">团队管理</li>
										<li><a href="gotoTeamList.do">团队管理</a></li>
									</c:if>

								</ul></li>
						</ul>

						<ul class="nav navbar-nav navbar-right">
							<li><a><img	 src="${currentUser.headimage}" width="27" height="27">
							</a></li>
							<li><a>HI!，${currentUser.userName}</a></li>
							<li class="dropdown"><a href="#" class="dropdown-toggle"
								data-toggle="dropdown"><span
									class="glyphicon glyphicon-bell"></span>${applyPartListSize}<strong
									class="caret"></strong></a>
								<ul class="dropdown-menu">
									<c:if test="${empty applyPartList}">

										<li><a href="gotoTeamDetail.do?teamid=${nowteamid}">暂时没有通知</a></li>
									</c:if>
									<c:if test="${not empty applyPartList}">
										<c:forEach var="applyUser" items="${applyPartList}">


											<li><a href="gotoTeamDetail.do?teamid=${nowteamid}">${applyUser.username}&nbsp;申请加入团队</a></li>

										</c:forEach>
										<li class="divider"></li>
										<li><a href="gotoTeamDetail.do?teamid=${nowteamid}">更多</a></li>
									</c:if>

								</ul></li>
							<li><a href="logout.do">注销</a></li>
						</ul>
					</div>

				</nav>
			</div>
		</div>



		<div class="row clearfix">
			<div class="col-md-3 column">
				<ul class="nav nav-stacked nav-tabs">
					<li class="active"><a
						href="gotoTeamDetail.do?teamid=${nowteamid}">团队</a></li>
					</br>
					<li><a href="gotoProjectList.do?teamid=${nowteamid}">项目</a></li>
					</br>
					<li><a href="gotoUserinfo.do?teamid=${nowteamid}">信息</a></li>

				</ul>
			</div>


			<div class="col-md-9 column">
				<div class="tabbable" id="tabs-458508">
					<ul class="nav nav-tabs">
						<li class="active"><a href="#panel-876035" data-toggle="tab">申请列表</a>
						</li>
						<li><a href="#panel-808913" data-toggle="tab">团队成员</a></li>
					</ul>
					<div class="tab-content">
						<div class="tab-pane active" id="panel-876035">


							<div class="table-responsive">
								<table class="table">
									<h3>团队创建者：${createUserName}</h3>
									<thead>
										<tr>
											<th><center>申请人姓名</center></th>
											<th><center>申请人邮箱</center></th>
											<th><center></center></th>

										</tr>
									</thead>
									<tbody>

										<c:if test="${empty applyAllList}">

										</c:if>
										<c:if test="${not empty applyAllList}">
											<c:forEach var="applyUser" items="${applyAllList}">
												<tr>
													<td><center>${applyUser.username}</center></td>
													<td><center>${applyUser.email}</center></td>
													<td><center>
															<c:if test="${applyUser.isaccepted == 0}">
																<button type="button" class="btn btn-primary"
																	onclick="passApply(${applyUser.userid})">通过申请</button>
															</c:if>
															<c:if test="${applyUser.isaccepted == 1}">
																<button type="button" class="btn btn-default "
																	disabled="disabled">已经通过</button>
															</c:if>
														</center></td>

												</tr>
											</c:forEach>
										</c:if>



									</tbody>
								</table>

								<center>




									<c:if test="${applyNowNo==1&&applyNowNo==applyTotalNo}">
										<ul class="pagination">
											<li><a>共${applyTotalNo}页</a></li>
											<li><a>Prev</a></li>
											<li><a>${applyNowNo}</a></li>
											<li><a>Next</a></li>
										</ul>
									</c:if>
									<c:if test="${applyNowNo==1&&applyNowNo!=applyTotalNo}">
										<ul class="pagination">
											<li><a>共${applyTotalNo}页</a></li>
											<li><a>Prev</a></li>
											<li><a>${applyNowNo}</a></li>
											<li><a
												href="appluUserFenYe.do?teamid=${nowteamid}&applyNowNo=${applyNowNo+1}">Next</a></li>
										</ul>
									</c:if>
									<c:if test="${applyNowNo==applyTotalNo && applyNowNo!=1}">
										<ul class="pagination">
											<li><a>共${applyTotalNo}页</a></li>
											<li><a
												href="appluUserFenYe.do?teamid=${nowteamid}&applyNowNo=${applyNowNo-1}">Prev</a></li>
											<li><a>${applyNowNo}</a></li>
											<li><a>Next</a></li>
										</ul>
									</c:if>
									<c:if test="${applyNowNo!=1&&applyNowNo!=applyTotalNo}">
										<ul class="pagination">
											<li><a>共${applyTotalNo}页</a></li>
											<li><a
												href="appluUserFenYe.do?teamid=${nowteamid}&applyNowNo=${applyNowNo-1}">Prev</a></li>
											<li><a>${applyNowNo}</a></li>
											<li><a
												href="appluUserFenYe.do?teamid=${nowteamid}&applyNowNo=${applyNowNo+1}">Next</a></li>
										</ul>
									</c:if>









								</center>

							</div>



						</div>
						<div class="tab-pane" id="panel-808913">



							<div class="typetop">

								<h3>所有成员</h3>
								团队创建者：${createUserName}
								<div class="typechild">
									<button type="button" class="btn btn-default btn-sm"
										onclick="changeType1()">
										<span class="glyphicon glyphicon-th-large"></span>
									</button>
									<button type="button" class="btn btn-default btn-sm"
										onclick="changeType2()">
										<span class="glyphicon glyphicon-th-list"></span>
									</button>
								</div>
							</div>



							<!-- type1 start -->
							<div id="type1">
								<div class="group">



									<c:if test="${empty teamUserList}">

									</c:if>
									<c:if test="${not empty teamUserList}">
										<c:forEach var="teamuser" items="${teamUserList}">
											<div class="grouplist">
												<div class="im">
													<img src="${teamuser.headimage}" height="100" width="100" />
												</div>
												<div class="imright">
													姓名：${teamuser.userName} </br> 邮箱：${teamuser.email}</br>
													电话:${teamuser.tel}</br> 团队评分：${teamuser.teamScore}</br>
													<c:if test="${teamuser.userName ne createUserName}">
														<button type="button" class="btn btn-default btn-sm"
															onclick="deleteTeamMember(${teamuser.userId},${nowteamid},${teamUserNowNo})">
															<span class="glyphicon glyphicon-remove"></span> Remove
														</button>
													</c:if>
													<c:if test="${teamuser.userName eq createUserName}">

													</c:if>

												</div>
											</div>
										</c:forEach>
									</c:if>










								</div>
							</div>
							<!-- type1 end -->




							<!-- type2 start -->
							<div id="type2">
								<div class="table-responsive">
									<table class="table">

										<thead>
											<tr>
												<th><center>成员名称</center></th>
												<th><center>成员评分</center></th>
												<th><center>移除</center></th>

											</tr>
										</thead>
										<tbody>


											<c:if test="${empty teamUserList}">

											</c:if>
											<c:if test="${not empty teamUserList}">
												<c:forEach var="teamuser" items="${teamUserList}">
													<tr>
														<td><center>${teamuser.userName}</center></td>
														<td><center>${teamuser.teamScore}</center></td>
														<td><center>
																<c:if test="${teamuser.userName ne createUserName}">
																	<button type="button" class="btn btn-default btn-sm" onclick="deleteTeamMember(${teamuser.userId},${nowteamid},${teamUserNowNo})">
																		<span class="glyphicon glyphicon-remove"></span>
																		Remove
																	</button>
																</c:if>
																<c:if test="${teamuser.userName eq createUserName}">

																</c:if>
															</center></td>

													</tr>
												</c:forEach>
											</c:if>



										</tbody>
									</table>
								</div>













							</div>
							<!-- type2 end -->




							<div id="teamUserFenYe" >
								<center>




									<c:if
										test="${teamUserNowNo==1&&teamUserNowNo==teamUserTotalNo}">
										<ul class="pagination">
											<li><a>共${teamUserTotalNo}页</a></li>
											<li><a>Prev</a></li>
											<li><a>${teamUserNowNo}</a></li>
											<li><a>Next</a></li>
										</ul>
									</c:if>
									<c:if
										test="${teamUserNowNo==1&&teamUserNowNo!=teamUserTotalNo}">
										<ul class="pagination">
											<li><a>共${teamUserTotalNo}页</a></li>
											<li><a>Prev</a></li>
											<li><a>${teamUserNowNo}</a></li>
											<li><a
												href="javascript:teamUserFenYe(${nowteamid},${teamUserNowNo+1})">Next</a></li>
										</ul>
									</c:if>
									<c:if
										test="${teamUserNowNo==teamUserTotalNo && teamUserNowNo!=1}">
										<ul class="pagination">
											<li><a>共${teamUserTotalNo}页</a></li>
											<li><a
												href="javascript:teamUserFenYe(${nowteamid},${teamUserNowNo-1})">Prev</a></li>
											<li><a>${teamUserNowNo}</a></li>
											<li><a>Next</a></li>
										</ul>
									</c:if>
									<c:if
										test="${teamUserNowNo!=1&&teamUserNowNo!=teamUserTotalNo}">
										<ul class="pagination">
											<li><a>共${teamUserTotalNo}页</a></li>
											<li><a
												href="javascript:teamUserFenYe(${nowteamid},${teamUserNowNo-1})">Prev</a></li>
											<li><a>${teamUserNowNo}</a></li>
											<li><a
												href="javascript:teamUserFenYe(${nowteamid},${teamUserNowNo+1})">Next</a></li>
										</ul>
									</c:if>




								</center>
							</div>





						</div>


					</div>
				</div>

			</div>
		</div>




	</div>
	<c:set var="createUserName" value="${pageContext.request.contextPath}"></c:set>
</body>
</html>

